<?php
/**
 * Created by PhpStorm.
 * User: wzy12
 * Date: 2018/10/18
 * Time: 0:04
 */

namespace app\common\model;


use think\Model;

class OrderAction extends Model
{
    public function operation($data){
        $data['log_time'] = time();

        $result = $this -> validate(true) -> allowField(true) -> isUpdate(false) -> save($data);
        if(false === $result){
            return echoArr(0, $this -> getError());
        }else{
            $time = '';
            if($data['pay_status'] == 1){
                $time = time();
            }
            $data['pay_time'] = $time;

            model('Order') -> allowField(true) -> isUpdate(true) -> save($data, ['id' => $data['order_id']]);

            return echoArr(1, '操作成功');
        }
    }
}